using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Dracham.GUI.Helpers
{
    public class TextboxKeyboardKey
    {
        private String key;
        private String text;
        private Boolean shift;
        private Boolean ctrl;
        private Boolean alt;

        #region properties 

        public Boolean Alt
        {
            get { return alt; }
            set { alt = value; }
        }

        public Boolean Ctrl
        {
            get { return ctrl; }
            set { ctrl = value; }
        }

        public String Key
        {
            get { return key; }
            set { key = value; }
        }

        public String Text
        {
            get { return text; }
            set { text = value; }
        }

        public Boolean Shift
        {
            get { return shift; }
            set { shift = value; }
        }

        #endregion

        public TextboxKeyboardKey(XmlNode keyNode)
        {
            this.key = keyNode.Attributes["Key"].Value.ToLower();
            this.text = keyNode.Attributes["Text"].Value;

            this.shift = ParseBoolean(keyNode, "Shift");
            this.alt = ParseBoolean(keyNode, "Alt");
            this.ctrl = ParseBoolean(keyNode, "Ctrl");
        }

        private Boolean ParseBoolean(XmlNode node, String attrName)
        {
            return node.Attributes[attrName] != null ?
                Boolean.Parse(node.Attributes[attrName].Value)
                :
                false;
        }
    }
}
